import requests as r
from pyquery import PyQuery as pq
import re
headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0'}
url='https://www.zhihu.com/question/50156569/answer/436152683'
rep=r.get(url,headers=headers).text
repro=re.compile('<h1 class="QuestionHeader-title">(.*?)</h1>').findall(rep)
cpc=re.compile('<span class="RichText ztext".*?>(.*?)</span>',re.S).findall(rep)
cvc=re.compile('<span class="RichText ztext.*?">.*?<p>(.*?)</span>').findall(rep)
for i in repro:
   # print('标题为:',i)
    pass
for p in cpc:
   # print('内容为:',p)
    pass
for v in cvc:
    v=v.replace('</p>','\n')
    #print('回复为:',v)
#print('标题为:',i)
#print('内容为:',p)
#print('回复为:',v)
cu=i+p+v
print(cu)
with open('1.txt','a')as l:
    l.write(cu)
    print('o的k')

